# Contributor: Michael Pirogov <vbnet.ru@gmail.com>
# Contributor: Joe Holden <jwh@zorins.us>
# Maintainer: Joe Holden <jwh@zorins.us>
pkgname=cockroach
pkgver=20.1.1
pkgrel=0
pkgdesc="The open source, cloud-native SQL database."
url="https://cockroachlabs.com"
arch="x86_64 aarch64"
license="Apache-2.0"
makedepends="go bash cmake autoconf linux-headers ncurses-dev coreutils"
install="$pkgname.pre-install"
pkgusers="cockroach"
pkggroups="cockroach"
subpackages="$pkgname-openrc"
options="!check" # tests are broken
source="$pkgname-v$pkgver.tar.gz::https://binaries.cockroachdb.com/cockroach-v$pkgver.src.tgz
	cockroach.initd
	cockroach.confd
	01_no_githooks.patch"

builddir=$srcdir/$pkgname-v$pkgver

# Fails with a permission denied error on some builders without this.
export GO111MODULE=off

build() {
	make TAGS="stdmalloc" BUILDTYPE="release" buildoss
}

package() {
	install -m755 -D $srcdir/$pkgname.initd $pkgdir/etc/init.d/$pkgname
	install -m644 -D $srcdir/$pkgname.confd $pkgdir/etc/conf.d/$pkgname
	install -m755 -o $pkgusers -g $pkggroups -D src/github.com/cockroachdb/$pkgname/${pkgname}oss $pkgdir/usr/sbin/$pkgname
}
sha512sums="cf1b2090e67b0fcc8b1f77458be06871965428c40c815393678ab64548cdbc54d5088a151fea63d25f9e3fcaeeeeff7ff5aae57bbad72a74841d8041535523ec  cockroach-v20.1.1.tar.gz
94264601b5b8516d87072017d40ba293d17320c706ad7a2e3c49f1af2b1030071e33cf3353adce26c634d284d0be4e41f2f9a9749c5071e9f0921ed03429f4cf  cockroach.initd
7039d17eb3c251d941bc73af2264c9618b59f8301165764371bf1539c46366d35496b2c00ea134731fd1ca9a0b362f9ba331b03aa62339f75e14504af9eb44f9  cockroach.confd
fe611479ba32a01a1ee7770170c54570cb4ac558fb756c44c90f9e31d59a5da74af81adf1e100e723d3956aea96748955919e5b000ee91d8f8fcb26cc678556f  01_no_githooks.patch"
